<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>变成三位一隔</title>
</head>
<body>
    

    <script>
        var num = 788950000;
        var str = num + '';
        console.log(str);
        let reg =  /(?=(?!\b)(\d{3})+$)/g;
        let s = str.replace(reg,',')
        console.log(s);


        {
        
            function formatStr (num) {
                let num = 788950000;
                let str = num + '';
                
            }


            let num = 788950000;
            let str = num + '';
            
            
        }
        
    
    </script>
</body>
</html>